define(function (require, exports, module) {
    var angular = require("angular");

    var api_prefix = G_CONFIG["api_prefix"]; //api前缀

    angular.module('publicNoService', [])
        .factory('httpGet', ['$http', function ($http) {
            return function (url, data) {
                if (!data) {
                    data = {};
                }
                if (!data.params) {
                    data.params = {};
                }
                data.params = $.extend(data.params, {"NEED_TOKEN": false, "USE_FORM_DATA": false});
                return $http.get(url, data);
            }
        }])
        .factory('httpPost', ['$http', function ($http) {
            return function (url, data) {
                if (!data) {
                    data = {};
                }
                data = $.extend(data, {"NEED_TOKEN": false, "USE_FORM_DATA": false});
                return $http.post(url, data);
            }
        }])
        .service('commonService', ["$http", "httpGet", "httpPost", function ($http, httpGet, httpPost) {
            return {
                queryAllOrganizations: function (data, search) {
                    search = search || '';
                    return httpGet(api_prefix + 'usermanage/organization/query-all-organizations' + search, data);
                },
                postStepOneData: function (data) {
                    return httpPost(api_prefix + 'authorization/weixin-user/step-one', $.extend({"USE_FORM_DATA": true}, data));
                },
                getStepTwoData: function () {
                    return httpGet(api_prefix + 'authorization/weixin-user/step-two');
                },
                getStepThreeData: function () {
                    return httpGet(api_prefix + 'authorization/weixin-user/step-three');
                },
                getAccount: function () {
                    return $http.get(api_prefix + 'authorization/weixin-user/edit-account');
                },
                save: function (params) {
                    return httpPost(api_prefix + 'authorization/weixin-user/save-account', params);
                },
                saveInEdit: function (params) {
                    return $http.post(api_prefix + 'authorization/weixin-user/save-account', $.extend({"USE_FORM_DATA": false}, params));
                }
            };
        }])
});